<template>
  <div class="hello">
    {{ name }} <span style="color: red">♥ </span>{{ girfriend }}
    <div class="block text-center">
      <span class="demonstration">回忆</span>
      <el-carousel height="300px">
        <el-carousel-item v-for="(item,index) in images" :key="index">
          <h3 class="small justify-center" text="2xl">{{ 1 }}</h3>
          <el-image
            style="width: 100%; height:300px"
            :src="item.url"
            :fit="fit"
          />
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
import { ref, reactive } from "vue";
export default {
  name: "HelloWorld",
  setup() {
    let name = ref("南巷小生");
    let girfriend = ref("胖成球");

    // 方法二：使用push 方法
    let images = reactive([]);
    function change() {
      let newArr = [
        {
          url: "http://picview.iituku.com/contentm/zhuanji/img/202207/09/e7196ac159f7cf2b.jpg/nu",
        },
        {
          url: "http://picview.iituku.com/contentm/zhuanji/img/202207/09/e7196ac159f7cf2b.jpg/nu",
        },
        {
          url: "http://picview.iituku.com/contentm/zhuanji/img/202207/09/e7196ac159f7cf2b.jpg/nu",
        },
        {
          url: "http://picview.iituku.com/contentm/zhuanji/img/202207/09/e7196ac159f7cf2b.jpg/nu",
        },
      ];
      images.push(...newArr);
    }
    return {
      name,
      girfriend,
      images
    };
  },
  props: {
    msg: String,
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.demonstration {
  color: var(--el-text-color-secondary);
}
::v-deep .el-carousel__container {
  width: 40%;
  margin: 0 auto;
}
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
